package com.blindnews.utils;


import com.alibaba.fastjson.JSON;
import com.alibaba.nls.client.protocol.NlsClient;
import com.baidu.aip.speech.AipSpeech;
import com.alibaba.fastjson.JSONObject;
public class AipClient {

    public final String APP_ID = "59569846";
    public final String API_KEY = "8wxSkMuctp0aNCkAC6a2WFVC";
    public final String SECRET_KEY = "PlLdKTudtaVPvdOyNxslFNuNO1p7Mv3J";

    // 初始化语音识别类
    AipSpeech client = new AipSpeech(APP_ID, API_KEY, SECRET_KEY);
    public JSONObject getSynthesis(String filePathName, String format){
        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000); //建立连接的超时时间（单位：毫秒）
        client.setSocketTimeoutInMillis(60000); //通过打开的连接传输数据的超时时间（单位：毫秒）
        org.json.JSONObject asrRes = client.asr(filePathName, format, 16000, null);
        System.out.println("打印结果：");
        System.out.println(asrRes);
        //转换成fastjson
        JSONObject jsonObject = JSON.parseObject(asrRes.toString());
        return jsonObject;
    }

}